package com.letoken.platform.repo.app.manager;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.app.dao.AppUserTeamMapper;
import com.letoken.platform.repo.app.po.AppUserTeam;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author wyl
 * @date 2023/1/1 12:18
 * @Version 1.0
 */
@Log4j2
@Repository
public class AppUserTeamManager {

    @Resource
    private AppUserTeamMapper teamMapper;

    /**
     * 修改所有上级的团队人数
     * @param inviteId   所有上级的id
     * @param teamMember
     * @return
     */
    public boolean addInviteTeamMember(String[] inviteId,Integer teamMember) {
        LambdaUpdateWrapper<AppUserTeam> teamUpdateWrapper = Wrappers.lambdaUpdate();
        teamUpdateWrapper.in(AppUserTeam::getUserId, inviteId);
        teamUpdateWrapper.setSql("team_member = team_member + " + teamMember + " + 1");
        int update = teamMapper.update(null, teamUpdateWrapper);
        return update > 0;
    }
}
